package day04;

import day02.Person;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * 要求用户输入若干员工信息，格式为：
 * name,age,gender,salary,hiredate;name,age,gender,salary,hiredate;....
 * 例如:
 * 张三,25,男,5000,2006-02-15;李四,26,女,6000,2007-12-24;...
 * 然后将每个员工信息解析成Emp对象。并存入到一个集合中。
 * 然后循环集合，输出每一个员工信息(输出使用toString返回的字符串)
 * 然后输出每个员工的转正仪式日期。
 * 转正仪式日期为:入职3个月的当周周五
 * 
 * @author Bonnie
 *
 */
public class Test09 {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入员工信息");
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        ArrayList<Object> list = new ArrayList<>();
        Scanner sc=new Scanner(System.in);
        String s = sc.next();
        String[] split = s.split(";");
        String[] workerTime=new String[split.length];
        for (int i = 0; i < split.length; i++) {
            String[] split1 = split[i].split(",");
            Emp p= new Emp(split1[0],Integer.parseInt(split1[1]),split1[2],
                    Integer.parseInt(split1[3]),simpleDateFormat.parse(split1[4]));
            list.add(p);
            Date date = simpleDateFormat.parse(split1[4]);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            calendar.add(Calendar.MONTH,3);
            calendar.set(Calendar.DAY_OF_WEEK,6);
            Date time = calendar.getTime();
            workerTime[i]=simpleDateFormat.format(time);
        }
        for (int i = 0; i < workerTime.length; i++) {
            System.out.println(list.get(i)+" 转正时间"+workerTime[i]);
        }
    }
}
